<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>PhysiTrack: D:/physi-tracklast/01/Android/PhysiTrack/src/graphview/LineGraphView.java Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">PhysiTrack
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.8.0 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Packages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">D:/physi-tracklast/01/Android/PhysiTrack/src/graphview/LineGraphView.java</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_line_graph_view_8java.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="keyword">package </span>graphview;
<a name="l00002"></a>00002 
<a name="l00003"></a>00003 <span class="keyword">import</span> android.content.Context;
<a name="l00004"></a>00004 <span class="keyword">import</span> android.graphics.Canvas;
<a name="l00005"></a>00005 <span class="keyword">import</span> android.graphics.Paint;
<a name="l00006"></a>00006 
<a name="l00015"></a><a class="code" href="classgraphview_1_1_line_graph_view.html">00015</a> <span class="keyword">public</span> <span class="keyword">class </span><a class="code" href="classgraphview_1_1_line_graph_view.html">LineGraphView</a> <span class="keyword">extends</span> <a class="code" href="classgraphview_1_1_graph_view.html">GraphView</a> {
<a name="l00016"></a><a class="code" href="classgraphview_1_1_line_graph_view.html#a1934a61352e5ca8f04d055b7fafa94d4">00016</a>         <span class="keyword">private</span> <span class="keyword">final</span> Paint <a class="code" href="classgraphview_1_1_line_graph_view.html#a1934a61352e5ca8f04d055b7fafa94d4">paintBackground</a>;
<a name="l00017"></a><a class="code" href="classgraphview_1_1_line_graph_view.html#aac08bdad785b14960906b9eb14805a69">00017</a>         <span class="keyword">private</span> <span class="keywordtype">boolean</span> <a class="code" href="classgraphview_1_1_line_graph_view.html#aac08bdad785b14960906b9eb14805a69">drawBackground</a>;
<a name="l00018"></a>00018 
<a name="l00019"></a><a class="code" href="classgraphview_1_1_line_graph_view.html#a3b72794b1032a9c1c95faab401e7d8d2">00019</a>         <span class="keyword">public</span> <a class="code" href="classgraphview_1_1_line_graph_view.html#a3b72794b1032a9c1c95faab401e7d8d2">LineGraphView</a>(Context context, String <a class="code" href="classgraphview_1_1_graph_view.html#a20903413edf006c4b5eafca915389f0e">title</a>) {
<a name="l00020"></a>00020                 super(context, title);
<a name="l00021"></a>00021 
<a name="l00022"></a>00022                 <a class="code" href="classgraphview_1_1_line_graph_view.html#a1934a61352e5ca8f04d055b7fafa94d4">paintBackground</a> = <span class="keyword">new</span> Paint();
<a name="l00023"></a>00023                 <a class="code" href="classgraphview_1_1_line_graph_view.html#a1934a61352e5ca8f04d055b7fafa94d4">paintBackground</a>.setARGB(255, 20, 40, 60);
<a name="l00024"></a>00024                 <a class="code" href="classgraphview_1_1_line_graph_view.html#a1934a61352e5ca8f04d055b7fafa94d4">paintBackground</a>.setStrokeWidth(4);
<a name="l00025"></a>00025         }
<a name="l00026"></a>00026 
<a name="l00027"></a>00027         @Override
<a name="l00028"></a><a class="code" href="classgraphview_1_1_line_graph_view.html#a40c7a9f0dadc19eb11dbc1263a68b8bf">00028</a>         <span class="keyword">public</span> <span class="keywordtype">void</span> <a class="code" href="classgraphview_1_1_line_graph_view.html#a40c7a9f0dadc19eb11dbc1263a68b8bf">drawSeries</a>(Canvas canvas, <a class="code" href="classgraphview_1_1_graph_view_1_1_graph_view_data.html">GraphViewData</a>[] values, <span class="keywordtype">float</span> graphwidth, <span class="keywordtype">float</span> graphheight, <span class="keywordtype">float</span> border, <span class="keywordtype">double</span> minX, <span class="keywordtype">double</span> minY, <span class="keywordtype">double</span> diffX, <span class="keywordtype">double</span> diffY, <span class="keywordtype">float</span> horstart) {
<a name="l00029"></a>00029                 <span class="comment">// draw background</span>
<a name="l00030"></a>00030                 <span class="keywordtype">double</span> lastEndY = 0;
<a name="l00031"></a>00031                 <span class="keywordtype">double</span> lastEndX = 0;
<a name="l00032"></a>00032                 <span class="keywordflow">if</span> (<a class="code" href="classgraphview_1_1_line_graph_view.html#aac08bdad785b14960906b9eb14805a69">drawBackground</a>) {
<a name="l00033"></a>00033                         <span class="keywordtype">float</span> startY = graphheight + border;
<a name="l00034"></a>00034                         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; values.length; i++) {
<a name="l00035"></a>00035                                 <span class="keywordtype">double</span> valY = values[i].<a class="code" href="classgraphview_1_1_graph_view_1_1_graph_view_data.html#aa897034d2c3a80d6c163e4adcc58686d">valueY</a> - minY;
<a name="l00036"></a>00036                                 <span class="keywordtype">double</span> ratY = valY / diffY;
<a name="l00037"></a>00037                                 <span class="keywordtype">double</span> y = graphheight * ratY;
<a name="l00038"></a>00038 
<a name="l00039"></a>00039                                 <span class="keywordtype">double</span> valX = values[i].<a class="code" href="classgraphview_1_1_graph_view_1_1_graph_view_data.html#a1c3566c49e3b6e6151e77683ce7572c9">valueX</a> - minX;
<a name="l00040"></a>00040                                 <span class="keywordtype">double</span> ratX = valX / diffX;
<a name="l00041"></a>00041                                 <span class="keywordtype">double</span> x = graphwidth * ratX;
<a name="l00042"></a>00042 
<a name="l00043"></a>00043                                 <span class="keywordtype">float</span> endX = (float) x + (horstart + 1);
<a name="l00044"></a>00044                                 <span class="keywordtype">float</span> endY = (float) (border - y) + graphheight +2;
<a name="l00045"></a>00045 
<a name="l00046"></a>00046                                 <span class="keywordflow">if</span> (i &gt; 0) {
<a name="l00047"></a>00047                                         <span class="comment">// fill space between last and current point</span>
<a name="l00048"></a>00048                                         <span class="keywordtype">int</span> numSpace = (int) ((endX - lastEndX) / 3f) +1;
<a name="l00049"></a>00049                                         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> xi=0; xi&lt;numSpace; xi++) {
<a name="l00050"></a>00050                                                 <span class="keywordtype">float</span> spaceX = (float) (lastEndX + ((endX-lastEndX)*xi/(numSpace-1)));
<a name="l00051"></a>00051                                                 <span class="keywordtype">float</span> spaceY = (float) (lastEndY + ((endY-lastEndY)*xi/(numSpace-1)));
<a name="l00052"></a>00052 
<a name="l00053"></a>00053                                                 <span class="comment">// start =&gt; bottom edge</span>
<a name="l00054"></a>00054                                                 <span class="keywordtype">float</span> startX = spaceX;
<a name="l00055"></a>00055 
<a name="l00056"></a>00056                                                 <span class="comment">// do not draw over the left edge</span>
<a name="l00057"></a>00057                                                 <span class="keywordflow">if</span> (startX-horstart &gt; 1) {
<a name="l00058"></a>00058                                                         canvas.drawLine(startX, startY, spaceX, spaceY, <a class="code" href="classgraphview_1_1_line_graph_view.html#a1934a61352e5ca8f04d055b7fafa94d4">paintBackground</a>);
<a name="l00059"></a>00059                                                 }
<a name="l00060"></a>00060                                         }
<a name="l00061"></a>00061                                 }
<a name="l00062"></a>00062 
<a name="l00063"></a>00063                                 lastEndY = endY;
<a name="l00064"></a>00064                                 lastEndX = endX;
<a name="l00065"></a>00065                         }
<a name="l00066"></a>00066                 }
<a name="l00067"></a>00067 
<a name="l00068"></a>00068                 <span class="comment">// draw data</span>
<a name="l00069"></a>00069                 lastEndY = 0;
<a name="l00070"></a>00070                 lastEndX = 0;
<a name="l00071"></a>00071                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; values.length; i++) {
<a name="l00072"></a>00072                         <span class="keywordtype">double</span> valY = values[i].<a class="code" href="classgraphview_1_1_graph_view_1_1_graph_view_data.html#aa897034d2c3a80d6c163e4adcc58686d">valueY</a> - minY;
<a name="l00073"></a>00073                         <span class="keywordtype">double</span> ratY = valY / diffY;
<a name="l00074"></a>00074                         <span class="keywordtype">double</span> y = graphheight * ratY;
<a name="l00075"></a>00075 
<a name="l00076"></a>00076                         <span class="keywordtype">double</span> valX = values[i].<a class="code" href="classgraphview_1_1_graph_view_1_1_graph_view_data.html#a1c3566c49e3b6e6151e77683ce7572c9">valueX</a> - minX;
<a name="l00077"></a>00077                         <span class="keywordtype">double</span> ratX = valX / diffX;
<a name="l00078"></a>00078                         <span class="keywordtype">double</span> x = graphwidth * ratX;
<a name="l00079"></a>00079 
<a name="l00080"></a>00080                         <span class="keywordflow">if</span> (i &gt; 0) {
<a name="l00081"></a>00081                                 <span class="keywordtype">float</span> startX = (float) lastEndX + (horstart + 1);
<a name="l00082"></a>00082                                 <span class="keywordtype">float</span> startY = (float) (border - lastEndY) + graphheight;
<a name="l00083"></a>00083                                 <span class="keywordtype">float</span> endX = (float) x + (horstart + 1);
<a name="l00084"></a>00084                                 <span class="keywordtype">float</span> endY = (float) (border - y) + graphheight;
<a name="l00085"></a>00085 
<a name="l00086"></a>00086                                 canvas.drawLine(startX, startY, endX, endY, <a class="code" href="classgraphview_1_1_graph_view.html#a36bb0610856b07bcf9018603a86b7e08">paint</a>);
<a name="l00087"></a>00087                         }
<a name="l00088"></a>00088                         lastEndY = y;
<a name="l00089"></a>00089                         lastEndX = x;
<a name="l00090"></a>00090                 }
<a name="l00091"></a>00091         }
<a name="l00092"></a>00092 
<a name="l00093"></a><a class="code" href="classgraphview_1_1_line_graph_view.html#ab0522b06b65dde3c3180ff684341dd22">00093</a>         <span class="keyword">public</span> <span class="keywordtype">boolean</span> <a class="code" href="classgraphview_1_1_line_graph_view.html#ab0522b06b65dde3c3180ff684341dd22">getDrawBackground</a>() {
<a name="l00094"></a>00094                 <span class="keywordflow">return</span> <a class="code" href="classgraphview_1_1_line_graph_view.html#aac08bdad785b14960906b9eb14805a69">drawBackground</a>;
<a name="l00095"></a>00095         }
<a name="l00096"></a>00096 
<a name="l00100"></a><a class="code" href="classgraphview_1_1_line_graph_view.html#a54a84247ebfcc1454995f11ec33ec701">00100</a>         <span class="keyword">public</span> <span class="keywordtype">void</span> <a class="code" href="classgraphview_1_1_line_graph_view.html#a54a84247ebfcc1454995f11ec33ec701">setDrawBackground</a>(<span class="keywordtype">boolean</span> <a class="code" href="classgraphview_1_1_line_graph_view.html#aac08bdad785b14960906b9eb14805a69">drawBackground</a>) {
<a name="l00101"></a>00101                 this.drawBackground = <a class="code" href="classgraphview_1_1_line_graph_view.html#aac08bdad785b14960906b9eb14805a69">drawBackground</a>;
<a name="l00102"></a>00102         }
<a name="l00103"></a>00103 }
</pre></div></div><!-- contents -->


<hr class="footer"/><address class="footer"><small>
Generated on Fri Jun 8 2012 00:07:22 for PhysiTrack by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.0
</small></address>

</body>
</html>
